import { locations } from "../../../gpu/locations";
const BasicMaterial =/*wgsl*/`
    override GAMM:f32=1.8;  
    fn linearToSRGB( color:vec3<f32>,gamm:vec3<f32>)->vec3<f32> {
      return pow(color, vec3(1.0 / gamm.x,1.0 / gamm.y,1.0 / gamm.z));
    }
    #include <AmbientLight_def>
    #include <HemisLight_def>
    #include <PunctusLight_def>
    #include <BasicMaterial_def>
    #include <Normal_def>
    #include <BasicMaterial_parse>
    #include <AlphaMap_def>
    #include <AoMap_def>
    #include <Line_def>
    #include <Camera>
    struct Input {
      #if ~{def.normal}
      @location(0) normal : vec3<f32>,
      #endif 
      #if ~{def.texCood0}
      @location(1) texCood0 : vec2<f32>,
      #endif
      #if ~{def.color}
      @location(4) color : vec4<f32>,
      #endif
      #if ~{def.uvWidthFactor}
      @location(5) uvWidthFactor : vec4<f32>,
      #endif
      @location(6) fragPosition:vec3<f32>,
      #if ~{def.logarithmicDepth}
      @location(7) flogz : f32,
      #endif
      @location(8) orgin:vec3<f32>,
    };
    struct Output {
      #if ~{def.logarithmicDepth}
        @builtin(frag_depth) fragDepth:f32,
      #endif
      @location(0) color:vec4<f32>,
      #if ~{def.gBuffer}
        @location(1) worldPos:vec4<f32>,
        @location(2) worldNormal:vec4<f32>,
        #if ~{def.enablePick}
        @location(3) pickColor:vec4<f32>,
        #endif
      #else
        #if ~{def.enablePick}
          @location(1) pickColor:vec4<f32>,
        #endif
      #endif
    };
    @fragment
    fn main(input:Input) -> Output {
      var output:Output;
      #include <BasicMaterial_rel>
      #include <NormalMap_rel>
      #include <AlphaMap_rel>
      #include <AoMap_rel>
      #include <HemisLight_rel>
      #include <AmbientLight_rel>
      #include <PunctusLight_rel>;
      #if ~{def.cameraSide}
        var l1:vec3<f32>=input.fragPosition-input.orgin;
        var l2:vec3<f32>=camera.position-input.orgin;
        if(dot(l1,l2)<=0){
          discard;
        }
      #endif
      #if ~{def.gBuffer}
        output.worldPos = vec4<f32>(input.fragPosition.xyz,1.0);
        //  output.worldNormal = vec4<f32>(n,1.0);
      #endif
      #if ~{def.map_uvPixel}
      var  map_uvPixel1:f32=map_uvPixel;
      #endif
      #if ~{def.map_uvOffset}
      var  map_uvOffset=map_uvOffset;
      #endif
      let color=output.color.xyz;
      output.color=vec4(linearToSRGB(color,vec3(GAMM)),output.color.w);
      #if ~{def.logarithmicDepth}
        output.fragDepth = log2(input.flogz ) * ~{def.logarithmicDepth} * 0.5;
      #endif
      return output;
    }`
export { BasicMaterial }